# Importing Data
HUNGARY<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Steel/TSA.xlsx",sheet = "Sheet1", range = "M1:M239")

# Checking the Imported Data
View(HUNGARY)
# Creating Time Series Data
HUNGARY_ts <- ts(HUNGARY, start=c(2000,1), end=c(2019,06), frequency=12)
# Viewing and Checking the Created Time Series Data
HUNGARY_ts
sum(is.na(HUNGARY_ts))
library(forecast)
HUNGARY_ts <- tsclean(HUNGARY_ts)
HUNGARY_ts

# Identification: Plotting the Time Series Data
plot(HUNGARY_ts)

# Estimating the appropriate model
HUNGARY_ts_model <- auto.arima(HUNGARY_ts)
HUNGARY_ts_model

# Forecasting
options(max.print=1000000)
HUNGARY_ts_forecast <- forecast (HUNGARY_ts_model, level=c(95), h=258)
plot(HUNGARY_ts_forecast)
HUNGARY_ts_forecast             

# Exporting
write.table(HUNGARY_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Steel/HUNGARY_TSA.csv", sep=",")
